from rest_framework.serializers import ModelSerializer
from rest_framework import serializers
from . import models


class CarTypeModelSerializer(ModelSerializer):
    class Meta:
        model = models.CarModel
        fields = ('id', 'name')


class CarListModelSerializer(ModelSerializer):
    # img_url = serializers.ImageField(source='car_img.img_url.all()')
    brand = serializers.CharField(source='brand.name')
    model = serializers.CharField(source='model.name')

    class Meta:
        model = models.Car
        fields = (
            'id',
            'brand',
            'model',
            'box_name',
            'seat',
            'img',
            'price',
            'cc',
            'get_store',
            'get_air',
            'consumption',
            'volume'
        )


class CarBrandModelSerializer(ModelSerializer):
    class Meta:
        model = models.CarBrand
        fields = (
            'id',
            'name'
        )
